<style>
<!--
.textbox-label {width: 150px;}
-->
</style>
<div class="easyui-panel" data-options="fit:true,title:'资源库编辑'" style="min-width:550px;">
	<form id="kform" class="easyui-form" style="margin:0px auto;width:70%;">
		<div>
			<input name="repName" class="easyui-textbox" data-options="label:'资源库名称:',labelAlign:'right',required:true,validType:['length[1,25]']" style="width:95%;"/>
	    </div>
	    <div>
	        <input id="krepType" name="repType" data-options="label:'资源库类型:',labelAlign:'right',panelHeight:'auto',editable:false,
	        	required:true,valueField:'value',textField:'label'" style="width:350px;"/>
	    </div>
	    <div>
	        <input name="repUsername" class="easyui-textbox" data-options="label:'登录资源库用户名:',labelAlign:'right',required:true,validType:['length[1,30]']" 
	        	style="width:95%;"/>
	    </div>
	    <div>
	        <input name="repPassword" type="password" class="easyui-textbox" data-options="label:'登录资源库密码:',labelAlign:'right',required:true,
	        	validType:['length[1,30]']" style="width:95%;"/>
	    </div>
	    <div class="krepoFile">
	        <input id="krepBasePath" name="repBasePath" class="easyui-textbox" data-options="label:'文件资源库路径:',labelAlign:'right',required:true,
	        	validType:['length[1,200]']" style="width:95%;"/>
	    </div>
	    
    	<div class="krepoDb">
    		<input id="kdbType" name="dbType" data-options="label:'数据库类型:',labelAlign:'right',required:true,editable:false,required:true,
    			valueField:'value',textField:'label'" style="width:350px;"/>
    	</div>
    	<div class="krepoDb">
    		<input id="kdbAccess" name="dbAccess" data-options="label:'数据库访问模式:',labelAlign:'right',required:true,editable:false,panelHeight:'auto',
    			valueField:'value',textField:'label'" style="width:350px;"/>
    	</div>
    	<div class="krepoDb">
    		<input id="kdbHost" name="dbHost" class="easyui-textbox" data-options="label:'数据库主机名或IP地址:',labelAlign:'right',required:true,
    			validType:['length[1,45]']" style="width:95%;"/>
    	</div>
    	<div class="krepoDb">
    		<input id="kdbPort" name="dbPort" class="easyui-textbox" data-options="label:'数据库端口号:',labelAlign:'right',required:true,
    			validType:['length[1,10]']" style="width:95%;"/>
    	</div>
    	<div class="krepoDb">
    		<input id="kdbName" name="dbName" class="easyui-textbox" data-options="label:'数据库名称:',labelAlign:'right',required:true,
    			validType:['length[1,20]']" style="width:95%;"/>
    	</div>
    	<div class="krepoDb">
    		<input id="kdbUsername" name="dbUsername" class="easyui-textbox" data-options="label:'数据库登录账号:',labelAlign:'right',required:true,
    			validType:['length[1,30]']" style="width:95%;"/>
    	</div>
    	<div class="krepoDb">
    		<input id="kdbPassword" type="password" name="dbPassword" class="easyui-textbox" flag="password" data-options="label:'数据库登录密码:',labelAlign:'right',
    			required:true,validType:['length[1,30]']" style="width:95%;"/>
    	</div>
    	<div>
    		<input name="describes" class="easyui-textbox" data-options="label:'描述:',labelAlign:'right',multiline:true,validType:['length[0,300]']" 
    			style="width:95%;height:80px;padding:5px;">
    	</div>
    	
    	<input type="hidden" name="id">
	</form>
	<div style="text-align:center;padding:5px">
		<a href="javascript:krepoTest()" class="easyui-linkbutton">测试连接</a>
		<a href="javascript:krepoSubmit(false)" class="easyui-linkbutton" data-options="iconCls:'icon-save'">保存</a>
		<a href="javascript:krepoClear()" class="easyui-linkbutton" data-options="iconCls:'icon-undo'">取消</a>
	</div>
</div>

<script type="text/javascript" src="cusy/js/repository.js"></script>
<script type="text/javascript">
$(function() {
	var kdbType = "#kdbType", kdbAccess = "#kdbAccess";
	$(krepType).combobox({ data: repoTypeData, onSelect: krepoSetRequired });
	$(kdbType).combobox({ data: dbTypeData });
	$(kdbAccess).combobox({ data: dbAccessData });
	
	$(kdbType).combobox("select", "MySQL");
	$(kdbAccess).combobox("select", "Native");
	
	$.get(reqRoute.repositoryGetById, { id: $(keditRepId).val() }, function(resultData) {
		if (resultData.status == successCode) {
			$(kform).form('load', resultData.data);
			try {
				if ("file" == resultData.data.repType) {
					$(kdbType).combobox("select", "MySQL");
					$(kdbAccess).combobox("select", "Native");
				}
			} catch(e) {}
		} else {
			$.messager.alert("提示", resultData.message, "error", function() {
				krepoClear();
			});
		}
	});
});
</script>